/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.activity.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import com.jeeplus.common.persistence.ActEntity;
import com.jeeplus.common.persistence.DataEntity;
import com.jeeplus.common.utils.Collections3;
import com.jeeplus.common.utils.IdGen;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.oa.entity.OaNotifyRecord;
import com.jeeplus.modules.project.entity.ProjectApply;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.modules.sys.entity.User;

/**
 * 活动管理Entity
 * @author lw
 * @version 2018-01-14
 */
public class Activity extends  ActEntity<Activity> {
	
	private static final long serialVersionUID = 1L;
	private String actName;	//名称
	private String activitiEvent;		// 类别
	private String sponsor;		// 主办
	private Date startTime;		// 时间
	private String addr;		// 地点
	private String content;		// 主要内容
	private String cost;		// 经费情况
	private String processNode;		// 流程节点
	private String deptApproveAdvice;		// 部门意见
	private String deptApproveSignature;		// 部门意见(签章)
	private Date deptApprovetDate;		// 部门意见(日期)
	private String deptLeaderAdvice;		// 部门分管院领导意见
	private String deptLeaderSignature;		// 部门分管院领导意见(签章)
	private Date deptLeaderDate;		// 部门分管院领导意见(日期)
	private String sciresearchDeptAdvice;		// 科研处意见
	private String sciresearchDeptSignature;		// 科研处意见(签章)
	private Date sciresearchDeptDate;		// 科研处意见(日期)
	private String bossLeaderAdvice;		// 分管科研院领导意见
	private String bossLeaderSignature;		// 分管科研院领导意见(签章)
	private Date bossLeaderDate;		// 分管科研院领导意见(日期)
	private String type;		// 1:活动登记，2:人员外出调研
	private Office office;		// 所属机构
	private User user;		// 用户id
	private String  filePath;
	private List<ActivityRecord>  activityRecordList = new ArrayList<ActivityRecord>();
	
	public Activity() {
		super();
	}

	public Activity(String id){
		super(id);
	}

	@ExcelField(title="名称", dictType="activiti_event", align=2, sort=7)
	public String getActivitiEvent() {
		return activitiEvent;
	}

	public void setActivitiEvent(String activitiEvent) {
		this.activitiEvent = activitiEvent;
	}
	
	@ExcelField(title="主办", align=2, sort=8)
	public String getSponsor() {
		return sponsor;
	}

	public void setSponsor(String sponsor) {
		this.sponsor = sponsor;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
	@ExcelField(title="时间", align=2, sort=9)
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	
	@ExcelField(title="地点", align=2, sort=10)
	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}
	
	public String getUsers() {
		return Collections3.extractToString(activityRecordList, "user.id", ",") ;
	}

	public void setUsers(String users) {
		this.activityRecordList = Lists.newArrayList();
		for (String id : StringUtils.split(users, ",")){
			ActivityRecord entity = new ActivityRecord();
			entity.setId(IdGen.uuid());
			entity.setActivity(this);
			entity.setUser(new User(id));
			entity.setCreateDate(new Date());
			this.activityRecordList.add(entity);
		}
	}
	public String getUsersName() {
		 String extractToString = Collections3.extractToString(activityRecordList, "user.name", ",") ;
		 return extractToString;
	}

	public void setUsersName(String usersName) {
		//nothing todo
	}

	@ExcelField(title="主要内容", align=2, sort=12)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	@ExcelField(title="经费情况", align=2, sort=13)
	public String getCost() {
		return cost;
	}

	public void setCost(String cost) {
		this.cost = cost;
	}
	
	@ExcelField(title="流程节点", align=2, sort=14)
	public String getProcessNode() {
		return processNode;
	}

	public void setProcessNode(String processNode) {
		this.processNode = processNode;
	}
	
	@ExcelField(title="部门意见", align=2, sort=15)
	public String getDeptApproveAdvice() {
		return deptApproveAdvice;
	}

	public void setDeptApproveAdvice(String deptApproveAdvice) {
		this.deptApproveAdvice = deptApproveAdvice;
	}
	
	@ExcelField(title="部门意见(签章)", align=2, sort=16)
	public String getDeptApproveSignature() {
		return deptApproveSignature;
	}

	public void setDeptApproveSignature(String deptApproveSignature) {
		this.deptApproveSignature = deptApproveSignature;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="部门意见(日期)", align=2, sort=17)
	public Date getDeptApprovetDate() {
		return deptApprovetDate;
	}

	public void setDeptApprovetDate(Date deptApprovetDate) {
		this.deptApprovetDate = deptApprovetDate;
	}
	
	@ExcelField(title="部门分管院领导意见", align=2, sort=18)
	public String getDeptLeaderAdvice() {
		return deptLeaderAdvice;
	}

	public void setDeptLeaderAdvice(String deptLeaderAdvice) {
		this.deptLeaderAdvice = deptLeaderAdvice;
	}
	
	@ExcelField(title="部门分管院领导意见(签章)", align=2, sort=19)
	public String getDeptLeaderSignature() {
		return deptLeaderSignature;
	}

	public void setDeptLeaderSignature(String deptLeaderSignature) {
		this.deptLeaderSignature = deptLeaderSignature;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="部门分管院领导意见(日期)", align=2, sort=20)
	public Date getDeptLeaderDate() {
		return deptLeaderDate;
	}

	public void setDeptLeaderDate(Date deptLeaderDate) {
		this.deptLeaderDate = deptLeaderDate;
	}
	
	@ExcelField(title="科研处意见", align=2, sort=21)
	public String getSciresearchDeptAdvice() {
		return sciresearchDeptAdvice;
	}

	public void setSciresearchDeptAdvice(String sciresearchDeptAdvice) {
		this.sciresearchDeptAdvice = sciresearchDeptAdvice;
	}
	
	@ExcelField(title="科研处意见(签章)", align=2, sort=22)
	public String getSciresearchDeptSignature() {
		return sciresearchDeptSignature;
	}

	public void setSciresearchDeptSignature(String sciresearchDeptSignature) {
		this.sciresearchDeptSignature = sciresearchDeptSignature;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="科研处意见(日期)", align=2, sort=23)
	public Date getSciresearchDeptDate() {
		return sciresearchDeptDate;
	}

	public void setSciresearchDeptDate(Date sciresearchDeptDate) {
		this.sciresearchDeptDate = sciresearchDeptDate;
	}
	
	@ExcelField(title="分管科研院领导意见", align=2, sort=24)
	public String getBossLeaderAdvice() {
		return bossLeaderAdvice;
	}

	public void setBossLeaderAdvice(String bossLeaderAdvice) {
		this.bossLeaderAdvice = bossLeaderAdvice;
	}
	
	@ExcelField(title="分管科研院领导意见(签章)", align=2, sort=25)
	public String getBossLeaderSignature() {
		return bossLeaderSignature;
	}

	public void setBossLeaderSignature(String bossLeaderSignature) {
		this.bossLeaderSignature = bossLeaderSignature;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="分管科研院领导意见(日期)", align=2, sort=26)
	public Date getBossLeaderDate() {
		return bossLeaderDate;
	}

	public void setBossLeaderDate(Date bossLeaderDate) {
		this.bossLeaderDate = bossLeaderDate;
	}
	
	@ExcelField(title="1:活动登记，2:人员外出调研", align=2, sort=27)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@ExcelField(title="所属机构", align=2, sort=28)
	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}
	
	@ExcelField(title="用户id", fieldType=User.class, value="user.name", align=2, sort=29)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<ActivityRecord> getActivityRecordList() {
		return activityRecordList;
	}

	public void setActivityRecordList(List<ActivityRecord> activityRecordList) {
		this.activityRecordList = activityRecordList;
	}

	public String getActName() {
		return actName;
	}

	public void setActName(String actName) {
		this.actName = actName;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
}